require_relative '../upload/Uploader'
class ActionUpload

  #/* 上传配置 */
  def ActionUpload.uploadconfig global_config,action,params
    base64 = :"upload"
    config = {}
    field_name = ''
    case action
      when :uploadimage
        config = {
            :pathFormat => global_config[:imagePathFormat.to_s],
            :maxSize => global_config[:imageMaxSize.to_s],
            :allowFiles => global_config[:imageAllowFiles.to_s]
        }

        field_name = global_config[:imageFieldName.to_s]
      when :uploadscrawl
        config = {
            :pathFormat => global_config[:scrawlPathFormat.to_s],
            :maxSize => global_config[:scrawlMaxSize.to_s],
            :allowFiles => global_config[:scrawlAllowFiles.to_s],
            :oriName => :"scrawl.png"
        }

        field_name = global_config[:scrawlFieldName.to_s]
        base64 = :base64
      when :uploadvideo
        config = {
            :pathFormat => global_config[:videoPathFormat.to_s],
            :maxSize => global_config[:videoMaxSize.to_s],
            :allowFiles => global_config[:videoAllowFiles.to_s]
        }

        field_name = global_config[:videoFieldName.to_s]
      when :uploadfile
        config = {
            :pathFormat => global_config[:filePathFormat.to_s],
            :maxSize => global_config[:fileMaxSize.to_s],
            :allowFiles => global_config[:fileAllowFiles.to_s]
        }

        field_name = global_config[:fileFieldName.to_s]
      when :uploadfile
    end
    upload_info = Uploader.new(field_name,config,base64,params)
    puts upload_info.getFileInfo
    return upload_info.getFileInfo
  end

end